﻿namespace LeetCodeProject._0001_1000._001_100._61_70._066;

public class Solution
{
    public int[] PlusOne(int[] digits)
    {
        if (digits.All(t => t == 9))
        {
            var result = new int[digits.Length + 1];
            result[0] = 1;
            return result;
        }
        else
        {
            var result = (int[])digits.Clone();
            var i = result.Length - 1;
            result[i]++;
            while (result[i] == 10)
            {
                result[i--] = 0;
                result[i]++;
            }

            return result;
        }
    }
}